int main()
{
	
	//TODO: GAME MODES AND STUFF
	//GM_Level mode as in the assebly...
	
	//additional stuff for demo mode here
	PLCSystem.ClearPLC();
	//fade out
	//separate loading for title cards
	
	PLCSystem.addPlc(levelheaders[level].plc)  //load level tiles (loaded to vram with plc management system)
	PLCSystem.addPlc(plcid_Main2)		       //load standard tiles (loaded to vram with plc management system)
	
	//clear RAM for objects (allocate mem)
	object *objects = new object[127];
	object *player = object[0];
	byte *v_objspace = new byte[127]
	byte *v_player = v_objspace; 
	
	//variable FFFFF628=0
    //iv_screenposx=0
	//v_oscillate+2=0
	
	//at this point in code we reconfigure video hardware with proper display mode
	
	//additional work for labyrinth
	//v_air = $30
	//load sonic's palette to foreground
	PalLoadFG(3);
	
	//if labyrinth then additional palette loading
	//if demo mode then we can skip displaying title card
	//determine zone music and playsound
	
	//create title card object in object RAM
	objects[2].init(id_TitleCard);
	
	while (objects[2].exists() && PLCSystem.exists())
	{
	//wait for next render then change rendering routine to $C
	
	//execute code for objects in object RAM (title card) (using objects funcptr)
	ExecuteObjects();
	
	//build proper sprites to represent objects in RAM (title card)
	BuildSprites();
	
	//finally run all pattern load cues
	PlcSystem.RunPLC(); 
	} //  if title card object still exists in RAM and card pattern load cues still exist then continue loop
	
	//TODO: learn Hud_Base, used to load HUD graphics
	
	//load sonics palette for HUD
	PalLoadBG(3);  //todo index value to lookup table
	
	//load level bounds/screen limits
	//load level start locations for sonic
	//   if a lamppost has been hit use its position for start location instead
	//if for some reason these start locations lie out of bounds then reposition sonic
	
	//TODO: create scroll value class to be used when rendering bg
	//load scroll values for current zone bg with bgScrollIndex
	//TODO: code for loop struct
	//load which 256s are loops for current zone w/LoopTileNums
	
	//TODO: additional ram values set
	
	//HANDLE SCROLLING WITH DEFORMLAYERS, A SCREEN CLASS SHALL BE CREATED TO REPRESENT THE SCREEN SCROLL VALUES TO USE WHEN RENDERING
	
	//LevelDataLoad for zone, will use the zone class
	LevelDataLoad(zone);
	
	//TODO: code for vram simulate
	//Draw Level Foreground and Background
	
	//TODO: learn unused collision value logging subroutine FloorLogUnk
	
	//TODO: COLLISION INDEX CODE
	//load collision index values for current zone
	
	//create sonic player object in object RAM
	object[0].init(1);    //TODO: THE INIT VALUE SHOULD BE FROM A TABLE OF VALS
	
	//if not in debug mode then create HUD object in object RAM
	if (f_debugmode != 1) { object[1].init(0x20); }
	//set f_debugmode if debug cheat has been entered and A button is held
	
	//DONT WORRY ABOUT FOR NOW: create water object in object RAM if zone is LZ
	
	//TODO CODE FOR SCREEN
	//create objects in object RAM for level objects v_opl_data that fall within screen range
	
	
	//execute handling code for each object (funcptr)
	ExecuteObjects();
	
	//TODO CODE FOR SPRITES AND RENDERING SPRITES
	//sprites created to represent each object, pointed at by the sprite table queue which is organized by priority from front to back in terms of display, buffered with the proper values in the sprite table buffer for direct transfer to sprite ram
	

	//If starting from lamppost (v_lamppost) then clear rings, time, and lives counter
	if (v_lamppost==0) 
	{
		ringsCounter = 0;
		timeCounter = 0; 
		livesCounter = 0;
	}
	
    //clear time over (f_timeover), sheild (v_sheild), invicibility (v_invinc), shoes (v_shoes), FFFFFE2F, v_debuguse, f_restart, v_framecount; also f_scorecount=1, f_ringcount=1, f_timecount=1, v_btnpushtime=0
	f_timeover = 0;
	v_sheild = 0;
	v_invinc = 0;
	v_shoes = 0;
	FFFFFE2FVal = 0;
	v_debuguse = 0;
	f_restart = 0;
	v_framecount = 0;
	f_scorecount = 1;
	f_ringcount = 1;
	f_timecount = 1
	v_btnpushtime = 0;
	
	//(v_zone*4)+DemoDataPtr used if we're in demo mode, load end sequence credits ptr and load key press duration using this ptr, subtract 1, v_demolength=1800, additional code for demo mode here, additional code for LZ
	
	//render routine switched to $8 (level mode)
	//optional to wait 3 additional renderings
	//v_pfade_start=#$202F
	//for demo mode clear title card art
	
	//change velocity of moving title card object RAM to make it move
	
	//MAIN GAME LOOP
	//if start is pressed then handling code for when paused
	//render routine switched to $8 (level mode) as this could be altered by the press of start
	//add 1 to game frame count
	//handle moving sonic object if demo mode
	//seperate object routine for water is executed if level LZ
	
	
	//execute handling code for all other objects (funcptr)
	ExecuteObjects();
	//if v_restart = 1 then restart everything from beginning of main()
	
	
	if (player->obRoutine==6 || (v_debugmode!=0))  //(hasnt just died) then
	{                           
	//   handle screen scrolling with deform layers (main call)
	}
	//if debug mode then handle screen scrolling with deform layers (allows to change to debug after death)
	
	//TODO: same as above ^
	//sprites created to represent each object, pointed at by the sprite table queue which is organized by priority from front to back in terms of display, buffered with the proper values in the sprite table buffer for direct transfer to sprite ram
	//create objects in object RAM for level objects v_opl_data that fall within screen range
	
	
	//TODO: palette cycling here, learn
	//run pattern load cues for these objects
	
	//TODO: oscillatenumdo, probably handles calculating some sort of oscillating value
	//change synchronized animation variables (rings, giant rings)
	//TODO: LEARN Load signpost object art
	//additional demo mode code
	if (v_restart == 1) { main(); }
	//if v_gamemode = #id_Level($C) then continue main game loop
	
}

